<?php

try {
	$debug = false;	//information if debuggin is enabled is needed from first line of code

	$root = dirname(__FILE__);
	$ds = DIRECTORY_SEPARATOR;
	set_include_path(	get_include_path() . PATH_SEPARATOR
						. $root. $ds . PATH_SEPARATOR  										//this dir
						. $root . $ds . 'Library' . $ds . PATH_SEPARATOR 		//library
						. $root . $ds . 'Application' . $ds );	//application
	require_once 'Library/includes.php'; // Include path settings specific for local machine

	// Initialize SmartL_Application
	require_once 'SmartL/Application.php';
	$application = SmartL_Application::getInstance();

	//Global cache for config - must be set manually before any config is loaded - after any change of configuration the cache must be deleted
	/*require_once 'Zend/Cache.php';
	SmartL_Config::setCache(Zend_Cache::factory('Core','File',array('lifetime'=>60),
		array('cache_dir'=>dirname(__FILE__).'/Application/Data/CacheConfig')));*/

	// Init application
	$application->init(dirname(__FILE__), "Application" . $ds . "Config");
	$debug = $application->isDebugMode();	//now we can set up debug according to config

	// Start dispatching
	$application->start();
}
catch (Exception $e) {
	if ( $debug ) {
		throw $e;
	}
	else {
		include 'Public/error.html';
	}
}